Heat series
A HeatSeries draws a grid of cells. Each point has an X and a Y coordinate, which place the cell, and a weight,
which sets its color: the weight is mapped to a gradient that goes from the lowest weight in the series to the
highest.
This article highlights the most used features. Every property is listed in the API explorer:
HeatSeries.
In XAML, declare it as XamlHeatSeries.
Basic heat map
The values of a heat series are usually
WeightedPoint instances, created with
new WeightedPoint(x, y, weight). In this sample X is the person and Y the month, and both axes use Labels to name
them. A point with a null X or Y is not drawn, and a null weight counts as 0.
Each cell is centered at its X and Y. Its size is the smallest distance between two X values, and between two Y values, of the series, so the points do not need to be one unit apart. The tooltip shows the label of the Y axis and the weight of the cell.
The chart in this sample also replaces the default legend with an SKHeatLegend, which draws the colors of the
HeatMap as a gradient, with the lowest and highest weights at its ends.

<UserControl
x:Class="AvaloniaSample.Heat.Basic.View"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:lvc="using:LiveChartsCore.SkiaSharpView.Avalonia"
xmlns:vms="using:ViewModelsSamples.Heat.Basic"
xmlns:draw="using:LiveChartsCore.SkiaSharpView.SKCharts"
x:DataType="vms:ViewModel">
<UserControl.DataContext>
<vms:ViewModel/>
</UserControl.DataContext>
<lvc:CartesianChart
LegendPosition="Right">
<lvc:CartesianChart.Series>
<lvc:XamlHeatSeries
Values="{Binding Values}"
HeatMap="{lvc:ColorArray '#FFF176, #2F4F4F, #0000FF'}"/>
</lvc:CartesianChart.Series>
<lvc:CartesianChart.XAxes>
<lvc:XamlAxis Labels="{Binding XLabels}"/>
</lvc:CartesianChart.XAxes>
<lvc:CartesianChart.YAxes>
<lvc:XamlAxis Labels="{Binding YLabels}"/>
</lvc:CartesianChart.YAxes>
<lvc:CartesianChart.Legend>
<draw:SKHeatLegend BadgePadding="{lvc:Padding '30, 20, 8, 20'}"/>
</lvc:CartesianChart.Legend>
</lvc:CartesianChart>
</UserControl>
using LiveChartsCore.Defaults;
namespace ViewModelsSamples.Heat.Basic;
public class ViewModel
{
public string[] XLabels { get; set; } =
["Charles", "Richard", "Ana", "Mari"];
public string[] YLabels { get; set; } =
["Jan", "Feb", "Mar", "Apr", "May", "Jun"];
public WeightedPoint[] Values { get; set; } = [
// Charles
new(0, 0, 150), // Jan
new(0, 1, 123), // Feb
new(0, 2, 310), // Mar
new(0, 3, 225), // Apr
new(0, 4, 473), // May
new(0, 5, 373), // Jun
// Richard
new(1, 0, 432), // Jan
new(1, 1, 312), // Feb
new(1, 2, 135), // Mar
new(1, 3, 78), // Apr
new(1, 4, 124), // May
new(1, 5, 423), // Jun
// Ana
new(2, 0, 543), // Jan
new(2, 1, 134), // Feb
new(2, 2, 524), // Mar
new(2, 3, 315), // Apr
new(2, 4, 145), // May
new(2, 5, 80), // Jun
// Mari
new(3, 0, 90), // Jan
new(3, 1, 123), // Feb
new(3, 2, 70), // Mar
new(3, 3, 123), // Apr
new(3, 4, 432), // May
new(3, 5, 142), // Jun
];
}
Heat map colors
HeatMap is an array of LvcColor, it needs
at least two colors. The first color is used for the lowest weight (the "coldest") and the last one for the highest
(the "hottest"), any weight in between gets a color interpolated linearly between them. You can add as many colors as
you need. In XAML, set it as a list of hex colors separated by commas, as the sample above does:
HeatMap="#FFF176, #2F4F4F, #0000FF".

using SkiaSharp;
using LiveChartsCore.SkiaSharpView;
Series = new ISeries[]
{
new HeatSeries<WeightedPoint>
{
HeatMap = new[] // mark
{ // mark
SKColors.Yellow.AsLvcColor(), // the first element is the "coldest" // mark
SKColors.Black.AsLvcColor(), // mark
SKColors.Blue.AsLvcColor() // the last element is the "hottest" // mark
}, // mark
Values = new ObservableCollection<WeightedPoint> { /* ... */ }
}
};
By default the gradient goes from the lowest to the highest weight in the series. Set MinValue and MaxValue to
fix that range, for example to keep the same colors while the data changes. Weights outside the range take the first
or the last color.
Color stops
By default the colors in the HeatMap are spread evenly along the gradient. ColorStops sets where each color is
placed, from 0 (the coldest) to 1 (the hottest), and must have one item for each color in the HeatMap. In the next
sample the black to blue part of the gradient only takes the last 10% of the range, and the yellow to black part
takes the other 90%.

using SkiaSharp;
using LiveChartsCore.SkiaSharpView;
Series = new ISeries[]
{
new HeatSeries<WeightedPoint>
{
HeatMap = new[]
{
SKColors.Yellow.AsLvcColor(), // the first element is the "coldest" // mark
SKColors.Black.AsLvcColor(), // mark
SKColors.Blue.AsLvcColor() // the last element is the "hottest" // mark
},
ColorStops = new[] // mark
{ // mark
0, // mark
0.9, // mark
1 // mark
}, // mark
Values = new ObservableCollection<WeightedPoint> { /* ... */ }
}
};
Point padding
PointPadding is the space, in pixels, between the edges of the cell and the drawn rectangle. It is 4 on every
side by default. This sample uses 20, with the data and axes of the basic sample:

Series = new ISeries[]
{
new HeatSeries<WeightedPoint>
{
PointPadding = new LiveChartsCore.Drawing.Padding(20), // mark
HeatMap = new[]
{
SKColor.Parse("#FFF176").AsLvcColor(), // the first element is the "coldest"
SKColor.Parse("#2F4F4F").AsLvcColor(),
SKColor.Parse("#0000FF").AsLvcColor() // the last element is the "hottest"
},
Values = new ObservableCollection<WeightedPoint> { /* ... */ }
}
};
Data labels
Setting DataLabelsPaint draws a label on every cell, in the middle of the cell by default. The default label is
the Y coordinate of the point, use DataLabelsFormatter to show the weight instead, it is the TertiaryValue of the
coordinate:
new HeatSeries<WeightedPoint>
{
Values = new ObservableCollection<WeightedPoint> { /* ... */ },
DataLabelsPaint = new SolidColorPaint(SKColors.White), // mark
DataLabelsSize = 12, // mark
DataLabelsFormatter = point => point.Coordinate.TertiaryValue.ToString("N0") // mark
}
Data, names and updates
Valuestakes anyIEnumerable<T>. Use anObservableCollection<T>and the chart animates every added, removed or replaced value.WeightedPointalso updates the chart when itsX,YorWeightchange, see automatic updates.- To plot your own types, see mappers.
Name(SeriesNamein XAML) is shown in tooltips. When it is not set, the tooltip shows the values without a series name.ZIndexsets which series draws on top, andIsVisibleshows or hides the series.